package cn.flying.base.web.auth.configuration;

import javax.servlet.http.HttpServletRequest;

import org.springframework.security.authentication.AuthenticationDetailsSource;
import org.springframework.security.web.authentication.WebAuthenticationDetails;
import org.springframework.stereotype.Component;

/**
 * @description: 该接口用于在Spring Security登录过程中对用户的登录信息的详细信息进行填充（主要填充http请求对象）
 * @author: lvyong
 * @date: 2023年05月26日 13:09
 * @version: 1.0
 */
@Component
public class CustomWebAuthenticationDetailsSource implements AuthenticationDetailsSource<HttpServletRequest, WebAuthenticationDetails> {


    /**
     * Called by a class when it wishes a new authentication details instance to be
     * created.
     *
     * @param context the request object, which may be used by the authentication details
     *                object
     * @return a fully-configured authentication details instance
     */
    @Override
    public WebAuthenticationDetails buildDetails(HttpServletRequest context) {
        return new CustomWebAuthenticationDetails(context);
    }
}
